package com.net.xpay.backend.scheduler;

import com.net.xpay.common.manager.ApiMonitorManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

/**
 * 2019/7/15 16:28

 */
@Slf4j
@Component
public class ApiMonitorCleanScheduler {

    @Autowired
    private ApiMonitorManager apiMonitorManager;


    /**
     * 清理历史监控数据
     */
    @Scheduled(cron = "0 0 4 * * *")
    public void cleanApiMonitor() {
        log.info("cleanApiMonitor start");

        //只保留6个月
        LocalDate deadline = LocalDate.now().minusMonths(6L);
        apiMonitorManager.deleteByMaxDay(deadline);

        log.info("cleanApiMonitor end");
    }




}
